const { readFile, baseUrl, request } = require('../base.js');
const Cookie = readFile('Cookie.txt');    //用户Cookie

/* 查询历史记录
* 传入参数 @params: {
*    lotid:类型
*    limit:数量
*    year:年份
* }
*/
module.exports = async function findHistory(lotid = '3d', limit = 300, year = "") {
  // console.log('检测',lotid, limit, year)
    try {
      const url = `${baseUrl}/api/kaijiang/getlist?lotid=${lotid}&limit=${limit}&year=${year}`;
      let res = await request({
        url,
        headers: {
            "accept": "*/*",
            "content-type": "application/x-www-form-urlencoded",
            "cookie": Cookie,
            "Referer": `${baseUrl}/kj/list-${lotid}.html`,
        },
        // body: `&lotid=${lotid}&limit=${limit}&year=${year}`,
        method: "POST"
      });
      return res;
    } catch (error) {
      return error;
    }
  }